home *** CD-ROM | disk | FTP | other *** search
/ Gekkan Dennou Club 143 / Gekkan Dennou Club - 2000.4 Vol. 143 (Japan).7z / Gekkan Dennou Club - 2000.4 Vol. 143 (Japan).bin / ikap / grp1 / smp1 / spctest.c < prev    next >
C/C++ Source or Header  |  2000-03-06  |  3KB  |  169 lines

  1. /*
  2. */
  3. #include    <stdio.h>
  4. #include    <stdlib.h>
  5. #include    <iocslib.h>
  6.  
  7. #include    "structs.inc"
  8.  
  9.  
  10. extern int    HEI0[],HEI1[];
  11.  
  12. TASK    ETask[MAX_ETASK];    /*クリック可能アイテム*/
  13.  
  14. int    dispPage=0;
  15.  
  16.  
  17. #define        SetTask(tn,na,x,y,an)    \
  18.         t=&ETask[(tn)];    \
  19.         t->disp0_addr=(na);    \
  20.         t->disp0_x=(x)<<16;    \
  21.         t->disp0_y=(y)<<16;    \
  22.         t->disp0_anim=(an)
  23.  
  24. int    Init000()
  25. {
  26.     TASK    *t;
  27.  
  28.     CRTMOD(270);
  29.     HOME(0,0,0);
  30.     cls();
  31.     sp_init();
  32.     v_priority("TSG","0123");
  33.     sp_disp(1);
  34.     sp_on(0,127);
  35.  
  36.     spfile_def("mue_m.SP",0x00);        /*スプライト読み込み*/
  37.     palfile_def("mue.PAL",0x01);
  38.  
  39. /*    t=&ETask[0]; t->disp0_addr=YOUW; t->disp0_x=128<<16; t->disp0_y=128<<16; t->disp0_anim=0;    */
  40.     SetTask(0,HEI0,128, 96,0);
  41.     SetTask(1,HEI1,132,160,0);
  42. }
  43.  
  44.  
  45.  
  46.  
  47. /*----------------------------------------------------------------------SyncMan()*/
  48.  
  49. #define        X6sp_set(pl,x,y,n,p)        \
  50.         X6sync_buf[(pl)*4+0]=(x);    \
  51.         X6sync_buf[(pl)*4+1]=(y);    \
  52.         X6sync_buf[(pl)*4+2]=(n);    \
  53.         X6sync_buf[(pl)*4+3]=(p)
  54.  
  55. short    X6sync_buf[128*4];
  56. int    SyncMan()
  57. {
  58.     int    ssp;
  59.     short    d,sppl;
  60.  
  61.     short    tn,sn,an,px,py,pat;
  62.     TASK    *t;            /*通常タスク*/
  63.  
  64.     SPINFO    *s;
  65.  
  66.     ssp=B_SUPER(0);
  67.  
  68.     sppl=0;
  69.     /*敵機
  70.     */
  71.     for( tn=0;tn<MAX_ETASK;tn++ ){
  72.         t=&ETask[tn];
  73. /*        if( t->func_addr==NULL ){    continue; }    */
  74.         if( t->disp0_addr==NULL ){    continue; }
  75.         s=t->disp0_addr;
  76.         if( s==NULL ){            continue; }
  77.         /*以下、表示
  78.         */
  79.         an=t->disp0_anim;
  80.         px=*(short *)&(t->disp0_x);
  81.         py=*(short *)&(t->disp0_y);
  82.         for( sn=0;sn<s->anim_info[t->disp0_anim]->chips;sn++ ){
  83.             px+=s->anim_info[t->disp0_anim]->splink[sn].ox;
  84.             py+=s->anim_info[t->disp0_anim]->splink[sn].oy;
  85.  
  86.             pat=s->anim_info[t->disp0_anim]->splink[sn].patnum;
  87.             if( t->disp0_palet!=0 ){
  88.                 pat&=0xf0ff;
  89.                 pat=pat|(t->disp0_palet<<8);
  90.             }
  91.  
  92.             X6sp_set(
  93.                 sppl,            /*実際に描画されるSPプレーン*/
  94.                 px,
  95.                 py,
  96.                 pat,
  97.                 3
  98.             );
  99.             sppl++;
  100.         }
  101.     }
  102.  
  103.  
  104.     /*スクロール
  105.     */
  106.     {
  107.         int    pn;
  108.         unsigned short    *spscr=0xEB0000,
  109.                 *sync=X6sync_buf;
  110.         for( pn=0;pn<min(sppl,128);pn++ ){
  111.             *spscr++=(*sync+16);sync++;
  112.             *spscr++=(*sync+16);sync++;
  113.             *spscr++=*sync++;
  114.             *spscr++=*sync++;
  115.         }
  116.         sp_off(sppl,127);
  117.     }
  118.  
  119.     {
  120.         unsigned short    *vctrl_r2=0xE82600;
  121.         *vctrl_r2|=0x0040;
  122.     }
  123.  
  124.     B_SUPER(ssp);
  125. }
  126.  
  127.  
  128.  
  129.  
  130. int    voffwait(times)
  131. int    times;
  132. {
  133.     volatile unsigned char    *gpip=0xe88001;
  134.     int    t,ssp;
  135.  
  136.     ssp=B_SUPER(0);
  137.     for( t=0;t<times;t++ ){
  138.         while((*gpip&0x10));
  139.         while(!(*gpip&0x10));
  140.     }
  141.     B_SUPER(ssp);
  142.  
  143. }
  144.  
  145.  
  146. main(argc,argv)
  147. int    argc;
  148. char    *argv[];
  149. {
  150.     int    mn0,mn1;
  151.     Init000();
  152.     mn0=(ETask[0].disp0_addr)->max_anim;
  153.     mn1=(ETask[1].disp0_addr)->max_anim;
  154.     while( BITSNS(0)!=0x02 ){
  155.         SyncMan();
  156.         ETask[0].disp0_anim=(ETask[0].disp0_anim<mn0-1)?ETask[0].disp0_anim+1:0;
  157.         ETask[1].disp0_anim=(ETask[1].disp0_anim<mn1-1)?ETask[1].disp0_anim+1:0;
  158.         if( argc!=1 ){    voffwait(atoi(argv[1]));    }
  159.         else{        getch();            }
  160.     }
  161.     while( BITSNS(0)==0x02 );
  162.     KFLUSHIO(0xff);
  163. }
  164.  
  165.  
  166.  
  167. /* [ EOF ] */
  168.  
  169.